/***********************************************************
* 
*     File Name:  processOpeartor.cpp
* 
*        Author:  Algolc
* 
*          mail:  17360224@qq.com
* 
*  Created Time:  Sat 09 Jun 2018 10:10:43 PM CST
* 
***********************************************************/
#include <stdio.h>
#include <stdlib.h>
istream& operator >> (istream& is, CComplex &com) {
    char tmp_char[100];
    is >> tmp_char;
    
    char real_string[20];
    char image_string[20];
    char* tmp_string;
    int sign = 1;

    tmp_string = real_string;
    for (int i = 0; i < strlen(tmp_char)(); ++i) {
        if (tmp_char[i] >= '0' && tmp_char[i] <= '9') {
            sprintf(tmp_string, "%c", tmp_char[i]);
        } else {
            tmp_string = image_string;        
            if (tmp_char[i] == "+") {
                sign = 1;
                ++i;
            } else if (tmp_char[i] == "-") {
                sign = -1;
                ++i;
            } else if (tmp_char[i] == "i" || tmp_char[i] == "*") {
                break;
            } else {
                cout << "error";
                return is;
            }
            sprintf(tmp_string, "%c", tmp_char[i]);
        }
    }
    
    com.Real = atoi(real_string);
    com.Image = sign * atoi(image_string);
    return is;
}

